#include<stdio.h>
int main(){
    int N,i,j,X;
    scanf("%d",&N);
    int a[N+1];
    for(i=0;i<N;i++)
        scanf("%d",&a[i]);
    scanf("%d",&X);
for(j=N-1;j>=0;j--)
    {
    if(a[j]>X)
        a[j+1]=a[j];
    else
       break;
    }
    a[j+1]=X;
    for(i=0;i<N+1;i++)
        printf("%d ",a[i]);
return 0;
}

